package JUnit;
/**
 * @author MIAO
 * Created on 2011-10-6
 * For more information, please visit:ismiao.com
 */


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import ismiao.com.test.JUnit.WordDealUtil;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class TestWordDealUtil {
	@Before
	public void echoBefore(){
		System.out.println("测试环境准备完成！可以开始测试！");
	}
	@After
	public void echoAfter(){
		System.out.println("测试结束！请查看结果！");
	}
	
	// 测试wordFormat4DB正常运行的情况
	@Test
	public void wordFormat4DBNormal() {
		String target = "employeeInfo";
		String result = WordDealUtil.wordFormat4DB(target);
		assertEquals("employee_info", result);
	}

	// 测试 null 时的处理情况
	@Ignore("直接抛出了异常测试错误（error）")
	@Test
	public void wordFormat4DBNull() {
		String target = null;
		String result = WordDealUtil.wordFormat4DB(target);
		assertNull(result);
	}

	// 测试空字符串的处理情况
	@Test
	public void wordFormat4DBEmpty() {
		String target = "";
		String result = WordDealUtil.wordFormat4DB(target);
		assertEquals("", result);
	}

	// 测试当首字母大写时的情况
	@Ignore("测试失败（failure）")
	@Test
	public void wordFormat4DBegin() {
		String target = "EmployeeInfo";
		String result = WordDealUtil.wordFormat4DB(target);
		assertEquals("employee_info", result);
	}

	// 测试当尾字母为大写时的情况
	@Test
	public void wordFormat4DBEnd() {
		String target = "employeeInfoA";
		String result = WordDealUtil.wordFormat4DB(target);
		assertEquals("employee_info_a", result);
	}

	// 测试多个相连字母大写时的情况
	@Test
	public void wordFormat4DBTogether() {
		String target = "employeeAInfo";
		String result = WordDealUtil.wordFormat4DB(target);
		assertEquals("employee_a_info", result);
	}
}